package com.example.springboot.thymeleaf.config;

import org.springframework.context.annotation.Bean;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.templateresolver.TemplateResolver;

/**
 * @desc
 * @Author wangsh
 * @date 2018/6/14 20:55
 */
//@Configuration
public class WebConfig {

	@Bean
	public TemplateResolver getTemplateResolver() {

		TemplateResolver viewResolver = new TemplateResolver();
		viewResolver.setSuffix(".html");
		viewResolver.setPrefix("classpath:/templates/");
		viewResolver.setTemplateMode("HTML5");
		return viewResolver;

	}


	@Bean
	public SpringTemplateEngine getTemplateEngine() {

		SpringTemplateEngine templateEngine = new SpringTemplateEngine();
		templateEngine.setTemplateResolver(getTemplateResolver());
		return templateEngine;
	}

	@Bean
	public ThymeleafViewResolver getThymeleafViewResolver() {

		ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
		viewResolver.setTemplateEngine(getTemplateEngine());
		return viewResolver;

	}

}
